﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace EasierRdp.Base
{
    abstract class RdpRef : INode
    {
        protected abstract RdpModel GetRefObject(int id);

        private RdpModel _reference;

        public RdpModel Ref
        {
            get { return _reference ?? (_reference = GetRefObject(Id)); }
        }

        public int Id { get; set; }

        public bool Default { get; set; }

        public string Name
        {
            get
            {
                return Ref.Name;
            }
        }

        public IEnumerable<INode> Children { get { return Enumerable.Empty<INode>(); } }

        public bool Expanded { get; set; }

        public abstract XElement ToXml();

        public const string
           AttributeName = "Name",
           AttributeDefault = "Default",
           AttributeId = "Id";

        public override string ToString()
        {
            return Ref.Name;
        }
    }
}
